﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customersearch.aspx.cs" Inherits="Ecreate.Web.popedom.usersearch.customersearch" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title></title>
    <script type="text/javascript"  src="/content/javascript/jquery/jquery-1.3.2.js" ></script>
    <script type="text/javascript"  src="/popedom/data/data_area.js" ></script>
    <script type="text/javascript"  src="/popedom/data/operatedata.js" ></script>  
    <script type="text/javascript"  src="/content/javascript/Calendar/calendar.js" ></script>      
    <script type="text/javascript"  src="/content/javascript/Aspnet.js" ></script>  
    <script type="text/javascript"  src="/popedom/data/json2.js" ></script>      
    <link rel="stylesheet" type="text/css" href="/content/css/tablestyle.css"/>        
    <script type="text/javascript">

        function gid(id) {
            return document.getElementById ? document.getElementById(id) : null;
        }
        function gidvalue(id) {

            var o = gid(id);

            if (o != null) {

                return o.value;
            }
            else {
                return "";
            }
        }

        function IsDate(datevalue) {
            ymd = datevalue.value.split("-");
            month = ymd[1] - 1
            var date = new Date(ymd[0], month, ymd[2]);
            if (date.getMonth() + 1 != ymd[1] || date.getDate() != ymd[2] || date.getFullYear() != ymd[0] || ymd[0].length != 4) {
                return false;
            }
            return true;
        }
        function checkDateId(id, label) {
            var date_input = gid(id);
            if (date_input == typeof (undefined)) {
                return false;
            }

            var value = date_input.value;

            if (value == "") {
                return true;
            }
            if (!IsDate(date_input)) {
                alert(label + "输入错误!非法日期,请依【YYYY-MM-DD】格式输入正确开始日期！");
                date_input.focus();
                return false;
            }
            return true;
        }
        function checkBetweenDate(idstart, idend) {

            var date_start_value = gidvalue(idstart);
            var date_end_value = gidvalue(idend);
            if (date_start_value != "" && date_end_value != "") {
                if (date_start_value > date_end_value) {
                    alert("非法日期,开始日期必须在结束日期之前！");
                    return false;
                }
            }
            return true;
        }

        function getValue(control) {


            if (control.val() == "undefined") {

                return control.attr["value"];
            }
            else {

                return control.val();
            }


        }




        function formCheck() {
            var ret = false;
            var checkvalue = false;
            checkvalue = $("#cb_create").attr("checked");
            if (checkvalue == true) {

                ret = checkDateId("create_s_date", "起始加盟日期");
                if (!ret) {
                    return false;
                }
                ret = checkDateId("create_e_date", "截止加盟日期");
                if (!ret) {
                    return false;
                }
                ret = checkBetweenDate("create_s_date", "create_e_date");
                if (!ret) return false;
            }
            checkvalue = $("#cb_cancel").attr("checked");
            if (checkvalue == true) {
                ret = checkDateId("can_s_date", "起始无效日期");
                if (!ret) return false;
                ret = checkDateId("can_e_date", "截止无效日期");
                if (!ret) return false;
                ret = checkBetweenDate("can_s_date", "can_e_date");
                if (!ret) return false;
            }








            var searchdata =

               [
                  { Field: "left(t.areacode,2)", Operate: '=', Value: '', ControlId: "sel_province", FieldType: "string" }
                , { Field: "left(t.areacode,4)", Operate: '=', Value: '', ControlId: "sel_city", FieldType: "string" }
                , { Field: "t.areacode", Operate: '=', Value: '', ControlId: "sel_country", FieldType: "string" }
                , { Field: "t.cus_id", Operate: '=', Value: '', ControlId: "txt_userid", FieldType: "string" }
                , { Field: "t.cus_tel", Operate: '=', Value: '', ControlId: "telephone", type: "string" }
                , { Field: "t.cus_account", Operate: '=', Value: '', ControlId: "account", FieldType: "string" }
                
                , { Field: "t.UseFlag", Operate: '=', Value: '', ControlId: "ddl_usestate", FieldType: "string" }
                , { Field: "t.createdate", Operate: '>=', Value: '', ControlId: "create_s_date", FieldType: "date" }
                , { Field: "t.createdate", Operate: '<=', Value: '', ControlId: "create_e_date", FieldType: "date" }

                , { Field: "t.canceldate", Operate: '>=', Value: '', ControlId: "can_s_date", FieldType: "date" }
                , { Field: "t.canceldate", Operate: '<=', Value: '', ControlId: "can_e_date", FieldType: "date" }

               ];



              $(searchdata).each(function() {

                  var v = $("#" + this.ControlId);
                  var controlvalue = getValue(v);
                  this.value = controlvalue;

              });





               var server_data = JSON.stringify(searchdata, null, null);
               __doPostBack_Net("btn_action", server_data);
        }


        $(document).ready(function() {


               $.getJSON(
                 "/popedom/data/json.ashx",
                 function(json) {
                     $.each(json, function(i) {
                         $("#ddl_usergroup").append(getOption(json[i].Id, json[i].Value));
                     })
                 });

        
            setArea("#sel_province", "#sel_city", "#sel_country");
            var ddl_usergroup = $("#ddl_usergroup");
            ddl_usergroup.change(function() {
                var selectedindex = this.selectedIndex;
                var selectValue = this.options[selectedindex].value;
                var arr = selectValue.split(".");


                if (arr[0] == "1") {
                    var qq = $("#qq");
                    qq.attr("disabled", "disabled");
                }
                else {
                    var qq = $("#qq");
                    qq.removeAttr("disabled");
                }

                if (arr[0] == "3") {

                    var sel_province = $("#sel_province");
                    sel_province.attr("disabled", "disabled");

                    var sel_city = $("#sel_city");
                    sel_city.attr("disabled", "disabled");

                    var sel_country = $("#sel_country");
                    sel_country.attr("disabled", "disabled");
                }
                else {

                    var sel_province = $("#sel_province");
                    sel_province.removeAttr("disabled");

                    var sel_city = $("#sel_city");
                    sel_city.removeAttr("disabled");

                    var sel_country = $("#sel_country");
                    sel_country.removeAttr("disabled");
                }
            });

         

        });
    </script>
    <style type="text/css">
        #searchdiv
        {
            margin:0 auto;
        }
        .clearboth
        {
            clear:both;	
        	
        }
        select
        {
        	width:120px;
            font-size:12px;
            border: 1px solid #D4D0C8;
        }
 
         
        INPUT{
	        border: 1px solid #D4D0C8;
	        width: 115px;
	        font-size:12px;
        }
        input.long
        {
	        background-color: #FFCC33;
        }
        input.short
        {
	        width: 20px;border: 0px;
        }
        input.button
        {
	        width: 50px;border: 0px;
        }
        ul li
        {
        	
        	font-size:12px;
        	
        } 
        #searchdiv
        {
            float:left;	
        }
        #datadiv
        {
            float:left;	
            
            margin:30px 0px  0px 0px;
        }
    </style>    
</head>
<body>
    <form id="form1" runat="server">
    <div>
      <div id="searchdiv" >
            <ul>
                <li>
                省份
                </li>
                <li>
                    <select id="sel_province">
                    </select>
                </li>
                <li>
                城市
                </li>                
                <li>
                    <select id="sel_city">
                    </select>
                </li>
                <li>
                乡县
                </li>                   
                <li>
                     <select id="sel_country">
                    </select>   
                </li>
                <li>
                  销售商编码
                </li>                 
                <li>
                    <input id="txt_customerid" type="text" />
                </li> 
                 <li>
                  电话
                </li>                 
                <li>
                    <input id="txt_telephone" type="text" />
                </li>   
                <li>
                  付款账号
                </li>  
                <li>
                    <input id="txt_account" type="text" />
                </li>   
                <li>
                 用户状态
                </li>  
                <li>
                    <asp:DropDownList ID="ddl_usestate" runat="server">
                    </asp:DropDownList>
                </li>
                <li>
              
                </li>                    
                 <li>

                          加盟日期<input id="cb_create" type="checkbox"  class="short" />
                    
                </li>   
                <li>
                                        <input id="create_s_date" type="text"  readonly="readonly" ondblclick="popUpCalendar(this, this ,'yyyy-mm-dd')" />
                </li>
                <li>
                                        <input id="create_e_date" type="text" readonly="readonly" ondblclick="popUpCalendar(this, this ,'yyyy-mm-dd')"  />
                </li>
                <li>
              
                </li>   
                 <li>
                          无效日期<input id="cb_cancel" type="checkbox" class="short" />
                    
                </li>      
                <li>
                                        <input id="can_s_date" type="text" readonly="readonly" ondblclick="popUpCalendar(this, this ,'yyyy-mm-dd')"/>

                
                </li>  
                <li>
                
                                        <input id="can_e_date" type="text" readonly="readonly" ondblclick="popUpCalendar(this, this ,'yyyy-mm-dd')" />

                </li>
                 <li>
                     <input id="btnsearch" type="button" value="查询" onclick=" return formCheck();" class="button" />
                </li>                                                                                                           
            </ul>     
      </div>
 
      <div id="datadiv">
          <asp:GridView ID="GridView1" runat="server">
          </asp:GridView>
          <asp:Button ID="btn_action" Visible="false"  runat="server" Text="Button" 
              onclick="btn_action_Click" />
      </div>           
    </div>
    </form>
</body>
</html>
